<?php
namespace app\admin\controller;
use think\Request;

class LargerActive extends Base
{
    protected function _initialize(){
        $this->checkLogin();
        $this->menuLoad();
    }

    public function index(){
        return $this->fetch('public/help');
    }

    public function largerActiveList(Request $request){
        $largerActive = new \app\admin\model\LargerActive();
        $where['id'] = ['neq',0];
        $rs = $largerActive->getPageAll($where);
        $this->assign('rs',$rs);
        return $this->fetch();
    }

    public function addLargerActive(Request $request){
        if($request->post()){
            $data = $request->post();
            $largerActive = new \app\admin\model\LargerActive();
            $rs = $largerActive->add($data);
            if($rs){
                return $this->success('添加成功');
            }else{
                return $this->error('添加失败');
            }
        }
        return $this->fetch();
    }

    public function editLargerActive(Request $request){
        $largerActive = new \app\admin\model\LargerActive();
        if($request->post()){
            $data = $request->post();
            $where['id'] = $data['id'];
            unset($data['id']);
            $rs = $largerActive->edit($where,$data);
            if($rs){
                return $this->success('修改成功');
            }else{
                return $this->error('修改失败');
            }
        }else{
            $data = $request->get();
            $where['id'] = $data['id'];
            $rs = $largerActive->getOne($where);
            $this->assign('rs',$rs);
        }
        return $this->fetch();
    }
}